package com.rede.didiok.admin.restapi.admin;


import java.util.List;

import javax.annotation.Resource;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.rede.didiok.admin.annotion.AuthorityVerify.AuthorityVerify;
import com.rede.didiok.admin.support.FileSupport;
import com.rede.didiok.common.dto.file.FileDto;
import com.rede.didiok.common.exception.ThrowableUtils;
import com.rede.didiok.common.feign.FileFeignClient;
import com.rede.didiok.common.utils.ResultUtil;
import com.rede.didiok.common.validator.group.GetList;

/**
 * 素材管理
 *
 * @author 陌溪
 * @date 2022年10月23日21:33:01
 */
@Api(value = "素材管理相关接口", tags = {"素材管理相关接口"})
@RestController
@RequestMapping("/admin/file")
@Slf4j
public class FileRestApi {

    @Resource
    private FileSupport fileSupport;

    @Resource
    private FileFeignClient fileFeignClient;

    @AuthorityVerify
    @ApiOperation(value = "获取素材列表", notes = "获取图片分类列表", response = String.class)
    @PostMapping(value = "/getList")
    public String getList(@Validated({GetList.class}) @RequestBody FileDto fileDto, BindingResult result) {
        // 参数校验
        ThrowableUtils.checkParamArgument(result);
        log.info("获取图片分类列表: {}", fileDto);
        return ResultUtil.successWithData(fileSupport.getFileList(fileDto));
    }

    @AuthorityVerify
    @ApiOperation(value = "批量删除素材列表", notes = "批量删除素材列表", response = String.class)
    @PostMapping(value = "/batchDeleteFile")
    public String batchDeleteFile(@RequestBody List<String> fileUidList) {
        log.info("批量删除");
        return fileSupport.batchDeleteFile(fileUidList);
    }
}

